﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.ConvertDecimalToBinary
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Input decimal number or 0 to exit:");
            
                int numberInDecimal = int.Parse(Console.ReadLine());
                if (numberInDecimal > 0)
                {
                    numberInDecimal = DecimalToBinary(numberInDecimal);
                    Main();
                }
                else if (numberInDecimal == 0)
                {
                    Console.WriteLine("BYE!");
                }
        }

        private static int DecimalToBinary(int num)
        {
            List<int> binaryNumber = new List<int>();
            while (num > 0)
            {
                binaryNumber.Add(num % 2);
                num = num / 2;
            }
            binaryNumber.Reverse();
            for (int i = 0; i < binaryNumber.Count; i++)
            {
                Console.Write("{0}", binaryNumber[i]);
            }
            Console.WriteLine();
            return num;
        }
    }
}